export default {
  qq: (rule, value, callback) => {
    let runoob = /^\\d{5,15}$/;
    let search = value.search(runoob);
    if (search < 0) {
      return callback(new Error('请输入正确的QQ号码'));
    }
    return callback();
  },
  phone: (rule, value, callback) => {
    let runoob = /^[1-9]\d{10}$/;
    let search = value.search(runoob);
    if (search < 0) {
      return callback(new Error('请输入正确的手机号码'));
    }
    return callback();
  },
  email: (rule, value, callback) => {
    let runoob = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
    let search = value.search(runoob);
    if (search < 0) {
      return callback(new Error('请输入正确的Email地址'));
    }
    return callback();
  },
  ip: (rule, value, callback) => {
    let runoob = /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/;
    let search = value.search(runoob);
    if (search < 0) {
      return callback(new Error('请输入正确的ip地址'));
    }
    return callback();
  },
  password: (rule, value, callback) => {
    let runoob = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/;
    let search = value.search(runoob);
    if (search < 0) {
      return callback(new Error('6-12位必须包含数字和字母'));
    }
    return callback();
  },
}
